export class Vector {
    static Zero: Vector = new Vector(0, 0);
    constructor(
        public readonly x: number,
        public readonly y: number,
    ) { }
    public add(v2: Vector) {
        return new Vector(
            this.x + v2.x,
            this.y + v2.y);
    }
    public sub(v2: Vector) {
        return new Vector(
            this.x - v2.x,
            this.y - v2.y);
    }
    public scale(s: number) {
        return new Vector(
            this.x * s,
            this.y * s);
    }
    public isZero() { return this.x == 0 && this.y == 0; }
    public length2() { return this.x ** 2 + this.y ** 2; }
    public length() { return this.length2() ** 0.5; }
    public idfy(s: number = 1) {
        return this.isZero()
            ? new Vector(s, 0)
            : this.scale(s / this.length());
    }
    public eq(v: Vector) { return this.x === v.x && this.y === v.y; }
}
